﻿<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="Ops.Mpc.ExampleApplication.DataPaging.DataPagingControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:presenters="clr-namespace:Ops.Mpc.Presenters;assembly=Ops.Mpc"
    xmlns:controllers="clr-namespace:Ops.Mpc.Controllers;assembly=Ops.Mpc"   
    xmlns:states="clr-namespace:Ops.Mpc.States;assembly=Ops.Mpc"   
    xmlns:datapagingmodels="clr-namespace:Ops.Mpc.ExampleApplication.DataPaging.Models" 
    xmlns:datapagingactions="clr-namespace:Ops.Mpc.ExampleApplication.DataPaging.Actions"      
    xmlns:actions="clr-namespace:Ops.Mpc.ExampleApplication.Actions"         

    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <presenters:Presenter x:Name="Presenter1" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
        <controllers:Controller>
            <controllers:Controller.Models>
                <datapagingmodels:DataPagingModel ItemName="DataPagingModel">
                    <datapagingmodels:DataPagingModel.GetPageAction >
                        <datapagingactions:GetPersonsPageStateAction ItemName="GetPageStateAction" BusyIndicatorModelItemName="BusyIndicatorModel" />
                    </datapagingmodels:DataPagingModel.GetPageAction>
                </datapagingmodels:DataPagingModel>
            </controllers:Controller.Models>
            <controllers:Controller.States>
                <states:State ItemName="DefaultState" AutoRun="True"  >
                    <states:StateTemplate>
                        <Grid>
                            <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="425" Width="550" >
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="auto" />
                                    <RowDefinition Height="auto" />
                                    <RowDefinition Height="*"  />
                                    <RowDefinition Height="auto" />
                                </Grid.RowDefinitions>
                                <TextBlock Grid.Row="0" Text="{Binding Models[DataPagingModel].Items.TotalItemCount,Mode=OneWay,StringFormat='Number of records: {0}'}" HorizontalAlignment="Right" Foreground="Blue"/>
                                <sdk:DataPager Grid.Row="1" Source="{Binding Models[DataPagingModel].Items}"  AutoEllipsis="True" NumericButtonCount="5" DisplayMode="FirstLastPreviousNextNumeric" IsTotalItemCountFixed="True"/>
                                <sdk:DataGrid Grid.Row="2" ItemsSource="{Binding Models[DataPagingModel].Items}" AutoGenerateColumns="False" >
                                    <sdk:DataGrid.Columns>
                                        <sdk:DataGridTemplateColumn>
                                            <sdk:DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate>
                                                    <HyperlinkButton HorizontalAlignment="Center" VerticalAlignment="Center" Content="Copy" Command="{Binding StateActions[CopyToClipboardStateAction], Source={StaticResource Resolver}}" CommandParameter="{Binding}"/>
                                                </DataTemplate>
                                            </sdk:DataGridTemplateColumn.CellTemplate>
                                        </sdk:DataGridTemplateColumn>
                                        <sdk:DataGridTextColumn Binding="{Binding PersonId}" Header="Person Id" />
                                        <sdk:DataGridTextColumn Binding="{Binding FirstName}" Header="First Name"/>
                                        <sdk:DataGridTextColumn Binding="{Binding LastName}" Header="Last Name"/>
                                    </sdk:DataGrid.Columns>
                                </sdk:DataGrid>
                                <sdk:DataPager Grid.Row="3" Source="{Binding Models[DataPagingModel].Items}"  AutoEllipsis="True" NumericButtonCount="5" DisplayMode="FirstLastPreviousNextNumeric" IsTotalItemCountFixed="True"/>
                            </Grid>
                        </Grid>
                    </states:StateTemplate>
                    <states:State.StateActions>
                        <states:CompositeStateAction ItemName="CompositeStateAction" BusyIndicatorModelItemName="BusyIndicatorModel" >
                            <actions:SetMainMessageStateAction ItemName="SetMainMessageStateAction" MessageId="DataPagingMessage" BusyIndicatorModelItemName="BusyIndicatorModel" />
                            <datapagingactions:GetPersonPagerStateAction ItemName="GetPersonPagerStateAction" BusyIndicatorModelItemName="BusyIndicatorModel"  />
                        </states:CompositeStateAction>
                        <datapagingactions:CopyToClipboardStateAction ItemName="CopyToClipboardStateAction" />
                     </states:State.StateActions>
                </states:State>
            </controllers:Controller.States>
        </controllers:Controller>
    </presenters:Presenter>

</UserControl>
